<div class="doc-item" id="doc-843"><h2 class="doc-item-name">exponential<span class="namespace">(clojure.contrib.probabilities.monte-carlo)</span></h2><ul class="var-arglists"><li>(<span class="var-name">exponential</span>  lambda)</li></ul><div class="var-docstring"><p>Transform a sequence of uniform random numbers in the interval [0, 1)
     into a sequence of exponential random numbers with parameter lambda.</p></div><div class="var-source"><pre>; clojure/contrib/probabilities/monte_carlo.clj:145
(with-monad state-m
  (defn exponential
    &quot;Transform a sequence of uniform random numbers in the interval [0, 1)
     into a sequence of exponential random numbers with parameter lambda.&quot;
    [lambda]
    (when (&lt;= lambda 0)
      (throw (IllegalArgumentException.
  	    &quot;exponential distribution requires a positive argument&quot;)))
    (let [neg-inv-lambda (- (/ lambda))
	  ; remove very small numbers to prevent log from returning -Infinity
	  not-too-small  (reject #(&lt; % 1e-323) stream-next)]
      (m-fmap #(* (. Math log %) neg-inv-lambda) not-too-small))))</pre></div><div class="license"><p>Copyright (c) Rich Hickey. All rights reserved.</p><p>The use and distribution terms for this software are covered by the <a href="http://opensource.org/licenses/eclipse-1.0.php">Eclipse Public License 1.0</a>, which can be found in the file
          epl-v10.html at the root of this distribution. By using this software
          in any fashion, you are agreeing to be bound by the terms of this
          license. You must not remove this notice, or any other, from this
          software.</p></div></div>